package com.ow.dva.util;

import java.util.Calendar;

public class DateOfMonth {

    public Integer getDeteOfMonth(){
        //        当月有多少天
        Calendar cale = Calendar.getInstance();
        cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 1);
        cale.set(Calendar.DAY_OF_MONTH, 0);
        int dateOfMonth = cale.getActualMaximum(Calendar.DATE);
        return dateOfMonth;
    }

    public Integer getVerify(Integer weight) {

        Integer dateOfMonth = getDeteOfMonth();

//        当前第几天
        int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

        int vt = 0;
        if (day - weight > 0) {
            vt = day - weight;
        }
        if (day - weight == 0) {
            vt = dateOfMonth;
        }
        if (day - weight == -1) {
            vt = dateOfMonth - 1;
        }
        if (day - weight == -2) {
            vt = dateOfMonth - 2;
        }
        if (day - weight == -3) {
            vt = dateOfMonth - 3;
        }
        if (day - weight == -4) {
            vt = dateOfMonth - 4;
        }
        if (day - weight == -5) {
            vt = dateOfMonth - 5;
        }
        if (day - weight == -6) {
            vt = dateOfMonth - 6;
        }
        if (day - weight == -7) {
            vt = dateOfMonth - 7;
        }
        if (day - weight == -8) {
            vt = dateOfMonth - 8;
        }
        if (day - weight == -9) {
            vt = dateOfMonth - 9;
        }
        if (day - weight == -10) {
            vt = dateOfMonth - 10;
        }
        if (day - weight == -11) {
            vt = dateOfMonth - 11;
        }
        if (day - weight == -12) {
            vt = dateOfMonth - 12;
        }
        if (day - weight == -13) {
            vt = dateOfMonth - 13;
        }
        if (day - weight == -14) {
            vt = dateOfMonth - 14;
        }
        return vt;

    }
}
